require('../css/sport.css');
//导入axios
const axios = require('../utils/http.js')

window.onload = function () {
    //页面跳转函数传参
    utils.footer('sport');

    let tit_big = document.querySelector('.tit_big');
    let curriculum_img = document.querySelector('.curriculum_img');
    let tit_small = document.querySelector('.tit_small');
    let new_curriculum = document.querySelector('.inner_html');
    let mewDom = document.querySelector('.new_curriculum');
    axios.get('/api/train/courseList').then(res => {

        const BASE_URL = 'http://47.96.154.185:3701'
        let list = res.data.data;
        let newCourse = list[0];
        console.log(list);
        console.log(newCourse);

        // 第0个课程就是最新课程
        mewDom.innerHTML += `
         <a href="./course.html?id=${newCourse.courseId}">
            <div class="curriculum_video">
                            <div>
                                <img src="${BASE_URL + newCourse.imgurl}" alt="" class="curriculum_img">
                            </div>
                            <div class="box1">
                                <div class="tit_big"> ${newCourse.name}</div>
                                <div class="tit_small">${newCourse.desc}</div>
                            </div>
            </div>
        </a>
        `;

        //课程列表渲染
        let html = '';
        list.forEach(item => {
            html += `
            <a href='./course.html?id=${item.courseId}'>
                <div class="curriculum_video1">
                    <img src="${BASE_URL + item.imgurl}" alt="">
                    <div class="tit_big1">${item.name}</div>
                    <div class="tit_small1">${item.desc}</div>
                </div>
            </a>
                `;
        })
        new_curriculum.innerHTML += html;

    })













}